<%
  # Redmine plugin for Document Management System "Features"
  #
  # Karel Pičman <karel.picman@kontron.com>
  #
  # This program is free software; you can redistribute it and/or
  # modify it under the terms of the GNU General Public License
  # as published by the Free Software Foundation; either version 2
  # of the License, or (at your option) any later version.
  #
  # This program is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU General Public License for more details.
  #
  # You should have received a copy of the GNU General Public License
  # along with this program; if not, write to the Free Software
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
%>

<h3 class="title"><%= l(:field_label_dmsf_workflow) %></h3>

<%= form_tag({ controller: 'dmsf_workflows', action: 'new_action'}, method: :post, id: 'new-action-form') do %>
  <%= hidden_field_tag :dmsf_workflow_step_assignment_id, params[:dmsf_workflow_step_assignment_id] %>
  <%= hidden_field_tag :dmsf_file_revision_id, params[:dmsf_file_revision_id] %>
  <%= hidden_field_tag :back_url, params[:back_url] %>
  <p>
    <label>
      <%= radio_button_tag 'step_action', DmsfWorkflowStepAction::ACTION_APPROVE, true, onclick: 'noteMandatory(false);' %>
      <%= l(:label_dmsf_wokflow_action_approve) %>
    </label>
  </p>  
  <p>
    <label>
      <%= radio_button_tag 'step_action', DmsfWorkflowStepAction::ACTION_REJECT, false, onclick: 'noteMandatory(true);' %>
      <%= l(:label_dmsf_wokflow_action_reject) %>
    </label>    
    <br>
    <%= text_area_tag :note, '', placeholder: l(:message_dmsf_wokflow_note), style: 'width: 90%' %>
  </p>

  <div>
    <%= label_tag 'delegate', l(:label_dmsf_wokflow_action_delegate) %><br>
    <%= text_field_tag 'user_search', nil %>    
    <%= late_javascript_tag "observeSearchfield('user_search', null, '#{escape_javascript autocomplete_for_user_dmsf_workflow_path(@dmsf_workflow, dmsf_workflow_step_assignment_id: params[:dmsf_workflow_step_assignment_id], dmsf_file_revision_id: params[:dmsf_file_revision_id])}')" %>
    <div id="dmsf_users_for_delegate">
      <%= render_principals_for_new_dmsf_workflow_users(
        @dmsf_workflow, params[:dmsf_workflow_step_assignment_id], params[:dmsf_file_revision_id]) %>
    </div>
  </div>
  
  <p class="buttons">
    <%= submit_tag l(:button_submit), name: 'commit' %>
    <%= submit_tag l(:button_cancel), name: 'cancel', onclick: 'hideModal(this);' %>
  </p>
<% end %>
